  {layout name="common/layout" /}
  <style>
  .box-btn{
	display: inline-block;
	margin:0 20px;
  }
  .box-btn>a{
	  color: #fff;
  }
  .btn-outerbox{
	text-align: center;
	margin-top: 50px;
  }
  .box p{
	  margin-top: 20px;
  }
  </style>
	<div class="dislpayArrow hidden-xs"><a class="pngfix" href="javascript:void(0);" onClick="displaynavbar(this)"></a></div>
<div class="Hui-article-box" style="margin-top: 37px;">
	
	<div class="newCrumbs ">图书订单信息
		</div>
	<div class="">
		<div class="confirm">
			当前状态：待发货
		</div>
		<div class="recond-titles">
			<h3>图书订单信息</h3>
		</div>
		<div class="recond-title" style="margin-top: 30px;">
			<span style="font-size: 16px;">付款时间：{$deliver_orderinfo.create_time|date="Y-m-d H:i:s",###}</span>
			<span style="margin-left: 300px;font-size: 16px;">租赁周期：{$deliver_orderinfo.rent_start_time|date="Y-m-d",###}至{$deliver_orderinfo.rent_end_time|date="Y-m-d",###}</span>
		</div>
					<table class="table table-border table-bg  table-bordered" style="margin-bottom: 20px;line-height: 30px;">
 						<tr class="text-c">
 							<td style="width: 220px;">会员卡</td>
 							<td>用户</td>
 							<td>图书数量</td>
							<td>订单状态</td>
							<td>用户留言</td>
  						</tr>
  						<tr style="height: 120px;" class="text-c">
 							<td style="width: 250px;">
								{if condition="$deliver_orderinfo.pay_type eq '0'"}
								{switch name="$deliver_orderinfo.rank"}
								{case value="1"}小状元计划{/case}
								{case value="2"}小博士计划{/case}
								{case value="3"}免费体验计划{/case}
								{/switch}
								-
								{switch name="$deliver_orderinfo.type"}
								{case value="1"}月卡{/case}
								{case value="2"}季卡{/case}
								{case value="3"}半年卡{/case}
								{case value="4"}年卡{/case}
								{/switch}
								({$deliver_orderinfo.card_no})
								{else/}
								绘本直购
								{/if}
							</td>
 							<td>{$deliver_orderinfo.user_phone}</td>
 							<td>{$deliver_orderinfo.book_num}</td>
 							<td><span>待发货</span></td>
							<td>{$deliver_orderinfo.user_message}</td>
  						</tr>
					</table>
		<div class="recond-titles" >
			<h3 >图书列表</h3>
		</div>
		<div class="detail_messBody">
			{foreach $deliver_orderinfo.book_list as $k => $v}
			<a href="{:url('Book/updateBook')}?bookid={$v['id']}">
				<p class="p-te"><span><img style="width:45px;height: 60px;" src="{$v['img_medium']}"/></span><span style="margin-left: 70px;">《{$v['title']}》</span><span style="margin-left: 20px;">{$v['publisher']}</span><span style="margin-left: 20px;">ISBN:{$v['isbn13']}</span></p>
			</a>
			{/foreach}
		</div>
		<div class="recond-titles">
			<h3>物流信息</h3>
		</div>
		<div class="box">
			<span>收货地址：</span>
			<span>{$deliver_orderinfo.address_name}</span>
			<span>{$deliver_orderinfo.mobile}</span>
            <span>{$deliver_orderinfo.province}{$deliver_orderinfo.city}{$deliver_orderinfo.district}{$deliver_orderinfo.address}</span>

			<form id="frm" method="post" enctype="multipart/form-data" onkeydown="if(event.keyCode==13){return false;}"  class="form-horizontal" action="{:url('book/deliverAdd')}">
				<input type="hidden" name="order_id" value="{$deliver_orderinfo.id}">
				<input id="ipt_company" value="" type="hidden" name="order_deliver_company" >
				<p>物流方式：<span style="margin-left:20px">快递</span></p>
				<span>物流公司</span>：
				 
				 <select id="select_Company" onchange="setCompanyValue()" class="input-text radius size-M"  name="order_deliver_logistics_name"  style="margin-left: 15px;">
				 <option value="0">请选择物流公司</option>
				 <option selected="selected" value="shunfeng">顺丰快递</option>
				 <option selected="selected" value="jd">京东快递</option>
                 <option value="shentong">申通快递</option>
                 <option value="zhongtong">中通快递</option>
                 <option value="yuantong">圆通快递</option>
                 <option value="yunda">韵达快递</option>
                 <option value="gdems">EMS快递</option>
                 <option value="quanfeng">全峰快递</option>
                 <option value="tiantian">天天快递</option>
                 <option value="debang">德邦快递</option>
                 <option value="huitong">百世快递</option>
                 <option value="zhaijisong">宅急送</option>
				 <option value="auto">其他</option>
				 </select>
				<br>
				<span>运单号：</span><input type="text" value="{$deliver_orderinfo.mail_no}" name="order_deliver_expressid" class="input-text radius size-M" style="margin-left: 33px;">
				<!--<button class="box-btn btn1 get_mailno" type="button" style="width: 120px;height: 40px;">获取顺丰运单号</button><br>-->
				<span style="top: -13px;position: relative;display:none;">备注：</span><input type="text" name="remark" class="input-text radius size-M" style="margin-left: 47px;margin-top: -5px;display:none;"><br>
				<div class="btn-outerbox">
						<button class="box-btn btn1" type="button" onclick="save()">发货</button>
						<button type="button"  class="box-btn btn2" onclick="returnpage();">返回</button>
				</div>
			</form>

		</div>
	</div>			
</div>
	

<script>
	$(function(){
		$.Huitab("#tab_demo .tabBar span","#tab_demo .tabCon","current","click","0");
	});
	var GG = {
        "kk":function(mm){
           var ym=mm;
        }
    };
	 
	$("#page").initPage(71,1,GG.kk);
	$("#page1").initPage(71,1,GG.kk);
	$("#page2").initPage(71,1,GG.kk);
	$("#page3").initPage(71,1,GG.kk);
	$("#page4").initPage(71,1,GG.kk);
	
	function setCompanyValue()
	{
	    $("#ipt_company").val($("#select_Company").find("option:selected").text());
	}
	$(".get_mailno").click(function () {
	    var order = "{$deliver_orderinfo.id}";
		$.post("{:url('Book/getSFMailno')}",{order:order},function (data) {
		    if(data.status == 1){
		        var mail_no = data.data.mailno;
                $("input[name='order_deliver_expressid']").val(mail_no);
			}else{
		        layer.msg(data.msg);
			}
        },'json');
    });

	function save()
	{
        if($("select[name='order_deliver_logistics_name']").val()== 0)
        {
            layer.msg("请先选择物流公司!");
            return false;
        }
		if($("input[name='order_deliver_expressid']").val()=="")
		{
			layer.msg("运单号不能为空!");
			return false;
		}
        if($("#ipt_company").val()=="")
        {
            $("#ipt_company").val($("#select_Company").find("option:selected").text());
        }
		var mail_no = "{$deliver_orderinfo.mail_no}";
        if(mail_no == '' || mail_no == null) {
            $.ajax({
                type: "POST",
                url: "<?php echo url('book/deliverAdd', '', false); ?>",
                dataType: 'json',
                cache: false,
                data: $('#frm').serialize(),
                success: function (data) {
                    if (data.status == 1) {
                        layer.msg("发货成功!");
                        location.href = "{:url('book/borrowOrder')}?type=2";
                    } else {
                        layer.msg(data.msg);
                    }

                },
                error: function (xhr, status, error) {
                    console.log(xhr);
                    console.log(status);
                    console.log(error);
                }
            });
        }else{
            $.ajax({
                type: "POST",
                url: "<?php echo url('book/deliverSave', '', false); ?>",
                dataType: 'json',
                cache: false,
                data: $('#frm').serialize(),
                success: function(data) {
                    if(data.status == 1)
                    {
                        layer.msg("发货成功!");
                        location.href="{:url('book/borrowOrder')}?type=2";
                    }else{
                        layer.msg(data.msg);
                    }

                },
                error: function(xhr, status, error) {
                    console.log(xhr);
                    console.log(status);
                    console.log(error);
                }
            });
        }
	}
	function returnpage()
	{
		 location.href="{:url('book/borrowOrder')}?type=2";
	}
</script>
 
 
 
 
 
 
 